/**
 *
 * Copyright (c) 2009-2016 Freedomotic team
 * http://freedomotic.com
 *
 * This file is part of Freedomotic
 *
 * This Program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This Program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Freedomotic; see the file COPYING.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

package com.freedomotic.plugins.gui;

import com.freedomotic.plugins.Scheduler;

/**
 *
 * @author Enrico Nicoletti
 */
public class ClockForm
        extends javax.swing.JFrame {

    private transient Scheduler plugin;

    /**
     * Creates a new form ClockForm.
     * 
     * @param plugin
     */
    public ClockForm(Scheduler plugin) {
        this.plugin = plugin;
        initComponents();
        spnResolution.setValue(plugin.getResolution());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings( "unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents(  )
    {
        jLabel1 = new javax.swing.JLabel(  );
        spnResolution = new javax.swing.JSpinner(  );

        setDefaultCloseOperation( javax.swing.WindowConstants.DISPOSE_ON_CLOSE );

        jLabel1.setText( "Timer Resolution (millisec):" );

        spnResolution.addChangeListener( new javax.swing.event.ChangeListener(  )
            {
                public void stateChanged( javax.swing.event.ChangeEvent evt )
                {
                    spnResolutionStateChanged( evt );
                }
            } );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane(  ) );
        getContentPane(  ).setLayout( layout );
        layout.setHorizontalGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                         .addGroup( layout.createSequentialGroup(  ).addContainerGap(  )
                                                          .addComponent( jLabel1 )
                                                          .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
                                                          .addComponent( spnResolution,
                                                                         javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                         javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                         javax.swing.GroupLayout.PREFERRED_SIZE )
                                                          .addContainerGap( 231, Short.MAX_VALUE ) ) );
        layout.setVerticalGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                       .addGroup( layout.createSequentialGroup(  ).addContainerGap(  )
                                                        .addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
                                                                         .addComponent( jLabel1 )
                                                                         .addComponent( spnResolution,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE ) )
                                                        .addContainerGap( 269, Short.MAX_VALUE ) ) );

        pack(  );
    } // </editor-fold>//GEN-END:initComponents

    private void spnResolutionStateChanged(javax.swing.event.ChangeEvent evt)    {//GEN-FIRST:event_spnResolutionStateChanged
        plugin.setResolution((Integer) spnResolution.getValue());
    }//GEN-LAST:event_spnResolutionStateChanged
      // Variables declaration - do not modify//GEN-BEGIN:variables

    private javax.swing.JLabel jLabel1;
    private javax.swing.JSpinner spnResolution;

    // End of variables declaration//GEN-END:variables
}
